package cn.com.dcsgo.config;

import org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer;

/**
 * 项目初始化类
 * 两个IoC容器 WebIoC ServiceIoC
 * ServiceIoC作为Root IoC容器
 * WebIoC作为子IoC容器
 * WebIoC可以访问ServiceIoC但ServiceIoC不能访问WebIoC
 *
 * @author Dcsgo
 * @since 2025/3/8 16:18
 */

public class ApplicationInitializer extends AbstractAnnotationConfigDispatcherServletInitializer {
    /**
     * ServiceIoC容器配置类
     *
     * @return Class []
     */
    @Override
    protected Class<?>[] getRootConfigClasses() {
        return new Class[]{DataSourceConfig.class, MyBatisConfig.class, ServiceConfig.class};
    }

    /**
     * WebIoC容器配置类
     *
     * @return Class []
     */
    @Override
    protected Class<?>[] getServletConfigClasses() {
        return new Class[]{MyWebHandlerInterceptor.class, WebConfig.class};
    }

    /**
     * dispatcherServlet 拦截路径
     *
     * @return String[]
     */
    @Override
    protected String[] getServletMappings() {
        return new String[]{"/"};
    }
}
